#include <stdio.h>
#include <string.h>

//#define STDIN
//#define DEBUG

char s1[1000], s2[1000];

int c[1000][1000];

void find_max_comman_seq()
{
#ifdef DEBUG
	printf("%s %s\n", s1, s2);
#endif
	int i, j;

	int s1len = strlen(s1);
	int s2len = strlen(s2);
	for (i = 0; i < s1len; i += 1)
	{
		for (j = 0; j < s2len; j += 1)
		{
			c[i][j] = 0;
		}
	}

	int max = 0;
	for (i = 0; i < s1len; i += 1)
	{
		for (j = 0; j < s2len; j += 1)
		{
			if (i == 0 && j == 0)
				c[i][j] = 0;
			if (s1[i] == s2[j])
				c[i][j] = c[i-1][j-1] + 1;
			if (s1[i] != s2[j])
				c[i][j] = c[i-1][j] > c[i][j-1] ? 
					c[i-1][j] : 
					c[i][j-1];
			if (max < c[i][j])
				max = c[i][j];
		}
	}

	printf("%d\n", max);

}

int main()
{
#ifdef STDIN
	freopen("bin/1458.in", "r", stdin);
#endif
	while (1)
	{
		if (scanf("%s", s1) == EOF)
			break;
		scanf("%s", s2);
		find_max_comman_seq();
	}

	return 0;
}
